set_project('learn_opengl')
set_version('0.0.1', {build = "%Y%m%d%H%M"})

set_languages('cxx11')
set_toolchains("clang")

-- xmake f -m debug 切换为debug模式
-- xmake f -m release 切换为release模式
if is_mode('debug') then
    add_cxxflags('-Wall', '-Wextra')
    set_symbols('debug')
    set_optimize('none')
else
    add_cxxflags('-Wall', '-Wextra')
    set_optimize('faster')
end

-- 设置目标文件输出目录
set_targetdir('build')

add_includedirs(
    'tools',
    'tools/window',
    'tools/shader',
    'tools/model'
)

target('tools')
    on_load(function (target)
        target:add(find_packages('glut', 'glu'))
    end)
    set_kind('static')
    add_files('tools/**.cpp')
target_end()

function build_test(example)
    target(example)
        on_load(function (target)
            target:add(find_packages('assimp'))
        end)
        -- 添加子工程依赖,优先编译依赖目标
        add_deps('tools')
        set_kind('binary')
        add_files('test/' .. example .. '.cpp')
    target_end()
end

-- build_test('test_shader')
-- build_test('test_vbo')
-- build_test('test_tetra')
-- build_test('test_model')
build_test('test_glutMouse')